<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button>增</button>
    <button>删</button>
    <button>查</button>
    <button>改</button>
    <script>
        var oBtns=document.querySelectorAll("button");

        oBtns[0].onclick=function(){
            document.cookie="uname=赛德克";
            document.cookie="age=24";
        }

        oBtns[1].onclick=function(){
            var date=new Date();
            date.setDate(date.getDate()-1);
            document.cookie="uname=vzsd;expires="+date;
            document.cookie="age=234;expires="+date;
        }

        oBtns[2].onclick=function(){
            var str=document.cookie;
            console.log(str);
        }

        oBtns[3].onclick=function(){
            document.cookie="uname=十点半";
            document.cookie="age=20";
        }
    </script>
</body>
</html>